﻿//此程序求一个整数数组的最大值、最小值、平均值和所有数组元素的和
using System;

namespace IntNum
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = { 3,8,12,5,6,3,2,26,13 };
            for (int i = 0; i < array.Length - 1; i++)
            {
                for (int j = 0; j < array.Length - i - 1; j++)
                {
                    if (array[j] > array[j + 1])
                    {
                        int temp = array[j];
                        array[j] = array[j + 1];
                        array[j + 1] = temp;
                    }
                }
            }
            //最大值
            Console.WriteLine("最大值为：" + array[array.Length - 1]);
            //最小值
            Console.WriteLine("最小值为：" + array[0]);

            //总和
            double sum = 0;
            for (int i = 0; i < array.Length; i++)
            {
                sum += array[i];
            }
            Console.Write("总和为：" + sum);
            Console.WriteLine();

            //平均值
            double p = sum / (array.Length);
            Console.Write("平均值为：" + p);
            Console.WriteLine();
        }
    }
}
